﻿using Gp.Scripts.Core;
using Gp.Scripts.Data.Skills;
using Gp.Scripts.Equip;
using Gp.Scripts.GUI;

namespace Gp.Scripts.Core {
    public abstract class WeaponAbilityEntity : SkillEntity{
        public WeaponEntity Weapon { get;}

        public WeaponAbilityEntityConfig WEntityConfig => null;

        protected virtual bool IsSelfSkill => true;
        
        //
        // public WeaponAbilityEntity(SkillEntityConfig config, WeaponEntity weapon) : base(config) {
        //     Weapon = weapon;
        // }
        
        
        public override CostWrapper SkillCostInfo() {
            return CostWrapper.Any(WEntityConfig.costInfo.ToCosts());
        }


        public static WeaponAbilityEntity Build<T>(WeaponEntity entity) where T : WeaponAbilityEntityConfig {
            return Global.Get<BattleSystemConfig>().RulesModel.GetData<T>().BuildWeaponSkill(entity);
        }


        public override SkillContext GetAIContext() {
            return SkillContext.Empty;
        }


        public override void Display() {
            // if (IsSelfSkill) Global.Get<GridBattleGUISystem>().ConformClick(TriggerSkill, CancelSkill);
            // else {
            //     base.Display();
            // }
        }

        // protected void TriggerSkill() {
        //     HumanExecute(new UnitSelectContext(UnitReference));
        // }
        //
        // protected void CancelSkill() {
        //     Global.Get<BattleSystem>().ToLastState();
        // }
        
        
        
        
        // public override void OnAbilitySelected(CellGrid cellGrid) {
        //     base.OnAbilitySelected(cellGrid);
        //     UnitReference.CombatantModel.SetSkillState(WData.animations);
        //     
        //     UnitReference.CombatantModel.PlayPreSkill();
        // }
        //
        // public override void OnAbilityDeselected(CellGrid cellGrid) {
        //     UnitReference.CombatantModel.PlayPostSkill();
        // }
        
        
    }


    public class WeaponAbilityEntity<T> : WeaponAbilityEntity where T : WeaponAbilityEntityConfig {
        // public WeaponAbilityEntity(T config, WeaponEntity weapon) : base(config, weapon) { }
        public new T WData => Config as T; 
    }
}